import get_system_message from '../utils/get_system_message'

class SystemService {
    static async browser(agent, ip, host) {
        return {
            msg: '获取浏览器信息成功',
            code: 200,
            data: {
                agent,
                ip,
                host
            }
        };
    }

    static async userip(req) {
        let ip
        try {
            ip = req.headers['x-forwarded-for'] ||
                req.connection.remoteAddress ||
                req.socket.remoteAddress ||
                req.connection.socket.remoteAddress;
        } catch (e) {
            ip = "";
        }

        return {
            msg: '获取用户ip成功',
            code: 200,
            data: ip
        };
    }

    static async system_message() {
        return {
            msg: '获取系统信息成功',
            code: 200,
            data: get_system_message
        };
    }
}
export default SystemService